🎖️GitЯра🎖️
Node / meshtastic / Meshtastic-Android / files / feature / map / src / commonTest / kotlin / org / meshtastic / feature / map / tiles / AttributionTest.kt
Displaying Raw • Download
feature/map/src/commonTest/kotlin/org/meshtastic/feature/map/tiles/AttributionTest.kt renovate/fastlane-2.x-lockfile (056eed64) Text, 2.54 KB
T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.feature.map.tiles
Tff7b72import T7ee787kotlin.test.Test
Tff7b72import T7ee787kotlin.test.assertEquals
Tff7b72import T7ee787kotlin.test.assertFalse
Tff7b72import T7ee787kotlin.test.assertTrue
Tff7b72class T56d364AttributionTest Tb4b4b4{
Tf0883e@Test
Tff7b72fun Td2a8ff`a link becomes its text`Tb4b4b4(Tb4b4b4) Tb4b4b4{
Te6edf3assertEqualsTb4b4b4(
Ta5d6ff"Ta5d6ff© OpenStreetMapTa5d6ff"Tb4b4b4,
Ta5d6ff"Ta5d6ff© <a href=Ta5d6ff\"Ta5d6ffhttps://www.openstreetmap.org/copyrightTa5d6ff\"Ta5d6ff>OpenStreetMap</a>Ta5d6ff"Tb4b4b4.Te6edf3attributionPlainTextTb4b4b4(Tb4b4b4)Tb4b4b4,
Tb4b4b4)
Tb4b4b4}
Tf0883e@Test
Tff7b72fun Td2a8ff`an escaped ampersand does not turn into a live entity`Tb4b4b4(Tb4b4b4) Tb4b4b4{
T8b949e// Decoding & first would leave a bare "©" for the next pass to render as ©.
Te6edf3assertEqualsTb4b4b4(Ta5d6ff"Ta5d6ff© ExampleTa5d6ff"Tb4b4b4, Ta5d6ff"Ta5d6ff&copy; ExampleTa5d6ff"Tb4b4b4.Te6edf3attributionPlainTextTb4b4b4(Tb4b4b4)Tb4b4b4)
Tb4b4b4}
Tf0883e@Test
Tff7b72fun Td2a8ff`every catalogue attribution renders as displayable text`Tb4b4b4(Tb4b4b4) Tb4b4b4{
T8b949e// The credit is not optional — OpenStreetMap's and Esri's tile policies both require it — so a source whose
T8b949e// attribution collapsed to nothing after tag stripping would be a silent compliance failure.
Tb4b4b4(Te6edf3MapTileCatalogueTb4b4b4.Te6edf3basemapsTb4b4b4.Te6edf3map Tb4b4b4{ Tffa657itTb4b4b4.Te6edf3spec Tb4b4b4} Tff7b72+ Te6edf3MapTileCatalogueTb4b4b4.Te6edf3overlaysTb4b4b4.Te6edf3map Tb4b4b4{ Tffa657itTb4b4b4.Te6edf3spec Tb4b4b4}Tb4b4b4)Tb4b4b4.Te6edf3forEach Tb4b4b4{ Te6edf3spec Tff7b72-Tff7b72>
Tff7b72val Te6edf3text Tff7b72= Te6edf3specTb4b4b4.Te6edf3attributionHtmlTff7b72?.Te6edf3attributionPlainTextTb4b4b4(Tb4b4b4)
Te6edf3assertTrueTb4b4b4(Tff7b72!Te6edf3textTb4b4b4.Te6edf3isNullOrBlankTb4b4b4(Tb4b4b4)Tb4b4b4, Ta5d6ff"Ta5d6ffan attribution rendered as nothingTa5d6ff"Tb4b4b4)
Te6edf3assertFalseTb4b4b4(Ta5d6ff'<' Tff7b72in Te6edf3text Tff7b72|Tff7b72| Ta5d6ff'&' Tff7b72in Te6edf3textTb4b4b4, Ta5d6ff"Ta5d6ffmarkup survived into displayed text: Tffd700$Te6edf3textTa5d6ff"Tb4b4b4)
Tb4b4b4}
Tb4b4b4}
Tf0883e@Test
Tff7b72fun Td2a8ff`basemap and overlay credits are joined without repeating one`Tb4b4b4(Tb4b4b4) Tb4b4b4{
Tff7b72val Te6edf3shared Tff7b72= Te6edf3RasterTileSpecTb4b4b4(Te6edf3tiles Tff7b72= Te6edf3listOfTb4b4b4(Ta5d6ff"Ta5d6ffhttps://a/{z}/{x}/{y}.pngTa5d6ff"Tb4b4b4)Tb4b4b4, Te6edf3attributionHtml Tff7b72= Ta5d6ff"Ta5d6ffNOAATa5d6ff"Tb4b4b4)
Te6edf3assertEqualsTb4b4b4(Ta5d6ff"Ta5d6ffNOAATa5d6ff"Tb4b4b4, Te6edf3mapAttributionTextTb4b4b4(Te6edf3basemap Tff7b72= Te6edf3sharedTb4b4b4, Te6edf3overlays Tff7b72= Te6edf3listOfTb4b4b4(Te6edf3sharedTb4b4b4)Tb4b4b4)Tb4b4b4)
Tb4b4b4}
Tf0883e@Test
Tff7b72fun Td2a8ff`nothing to credit is an empty line rather than a stray separator`Tb4b4b4(Tb4b4b4) Tb4b4b4{
Te6edf3assertEqualsTb4b4b4(Ta5d6ff"Ta5d6ff"Tb4b4b4, Te6edf3mapAttributionTextTb4b4b4(Te6edf3basemap Tff7b72= Tff7b72nullTb4b4b4, Te6edf3overlays Tff7b72= Te6edf3emptyListTb4b4b4(Tb4b4b4)Tb4b4b4)Tb4b4b4)
Tb4b4b4}
Tb4b4b4}
Served by rngit 1.5.3 - Generated in 0.09s